<?php
# ***** BEGIN LICENSE BLOCK *****
# This file is part of "myWiWall".
# Copyright (c) 2007-2008 CRP Henri Tudor and contributors.
# All rights reserved.
#
# "myWiWall" is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
# 
# "myWiWall" is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with "myWiWall"; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# ***** END LICENSE BLOCK *****

?>

<h1><?php echo __("Categories Management"); ?></h1>

<form class="add_form" id="add_category" enctype="multipart/form-data" action="../../index.php/adminCategories/add" method="post">
	<fieldset>
		<legend><?php echo __("Create a new category"); ?>:</legend>
		<div class="form_line"><label for="category_name"><?php echo __("Category name"); ?> : </label><input class="text" type="text" id="category_name" name="category" maxlength="40"/></div>
		
		<div class="submit">
			<input class="button" type="submit" value="<?php echo __("Create"); ?>"/>
			<input class="button" type="reset" value="<?php echo __("Cancel"); ?>"/>
		</div>
	</fieldset>
</form>
		
<?php foreach ($categories as $category): ?>

	<div class="item <?php echo (($i++) % 2 == 0) ? 'even' : 'odd' ?>">
		<div class="name"><?php echo htmlspecialchars($category['category']) ?></div>
		<div class="control">
			<a href=# id="e_<?php echo $category['id']; ?>" class="editOption control" title="<?php echo __("Edit category"); ?>"><img src="../../views/<?php echo $GLOBALS['dir_theme'] ?>img/admin-categories-edit.png" alt="<?php echo __("Edit category"); ?>" class="controlImage"/></a>
			<a href=# id="d_<?php echo $category['id']; ?>" class="deleteOption control" title="<?php echo __("Delete category"); ?>"><img src="../../views/<?php echo $GLOBALS['dir_theme'] ?>img/admin-categories-delete.png" alt="<?php echo __("Delete category"); ?>" class="controlImage"/></a>
		</div>
	</div>
	
	<div id='editContainer_<?php echo $category['id'];?>' class='edit container' style='display: none;'>
		<form class="form_container" enctype="multipart/form-data" action="../../index.php/adminCategories/edit" method="post">
		<div class="edit_message"><?php printf(__("Modify the name of the '%s' category."), $category['category']); ?>:</div>
		<div class="form_line"><label><?php echo __("Category name"); ?> : </label><input class="text" type="text" name="categoryName" maxlength="40" value="<?php echo $category['category']; ?>"/></div>
		
		<input name="categoryId" type="hidden" value="<?php echo $category['id']; ?>"/>
		<input class="button" type="submit" value="<?php echo __("Edit"); ?>"/>
		<input class="button" type="reset" value="<?php echo __("Cancel"); ?>"/>
		</form>
	</div>
	
	<div id="deleteContainer_<?php echo $category['id'] ?>" class="delete container" style="display: none;">
		<form class="form_container" action="../../index.php/adminCategories/delete" method="post">
		<div class="edit_message"><?php printf(__("Are you sure you want to delete the '%s' category ?"), htmlspecialchars($category['category'])); ?></div>
		
		<input name="categoryId" type="hidden" value="<?php echo $category['id'] ?>"/>
		<input class="button" type="submit" value="<?php echo __('Delete'); ?>"/>
		<input class="button" type="reset" value="<?php echo __('Cancel'); ?>"/>
		</form>
	</div>

<?php endforeach; ?>